package org.springforge.forgeweb.mvc;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class SecurityHandlerInterceptor extends HandlerInterceptorAdapter {

	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 
	throws IOException{
		if ( request.getSession().getAttribute("user") == null )
		{
			if(	!request.getRequestURI().equals("/forge/user/login.html") && 
				!request.getRequestURI().equals("/forge/user/create.html"))
			{
			response.sendRedirect("/forge");
			return false;
			}
		}
		return true;
	}
}
